package 机试题16年;

import java.util.Scanner;

/**
 * Created by hest0 on 2017/4/19.
 */
public class 投篮游戏 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int p = sc.nextInt();
            int n = sc.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }
            System.out.println(basketBall(p, n, a));
        }
        sc.close();
    }

    private static int basketBall(int p, int n, int[] a) {
        boolean[] flag = new boolean[p];
        for (int i = 0; i < n; i++) {
            int idx = a[i] % p;
            if (flag[idx] == true)
                return i + 1;
            else
                flag[idx] = true;
        }
        return -1;
    }

}
